package main

import (
	"http"
	"os"
	"flag"
)

var port *string

func hello (w http.ResponseWriter, req *http.Request) {

	w.Write([]byte("hello world from port " + *port))
}

func try (err os.Error) {

	if err != nil {
		panic (err)
	}
}

func root (w http.ResponseWriter, req *http.Request) {

	w.Write([]byte("root path on " + *port))
}

func main () {

	port = flag.String("port", "8001", "port to listen on")
	flag.Parse()

	http.HandleFunc("/hello", hello)
	http.HandleFunc("/", root)

	try(http.ListenAndServe(":" + *port, nil))
}
